package com.zr.controller;
/**
 * 
 * @author CY
 *
 */
import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.zr.model.User;
import com.zr.service.FunctionService;
import com.zr.serviceImpl.FunctionServiceImpl;

import net.sf.json.JSONArray;



public class FindFuncController extends HttpServlet{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	FunctionService  functions = new FunctionServiceImpl();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(req, resp);
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		resp.setCharacterEncoding("utf8");
		HttpSession  session = req.getSession();
		User u = (User)session.getAttribute("user");
		PrintWriter  pw = resp.getWriter();
		JSONArray j = functions.getUserFunctionByDepartment(u.getUserdid(), 1);
		pw.write(j.toString());
		pw.flush();
		pw.close();
	}
}
